package com.admin.config;

import com.admin.fen.Adminfenmemediafeign;
import com.admin.service.ipl.WemediaNewsAutoScanService;
import com.usian.model.media.pojos.WmNews;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;


@Component
public class HelloJob {

    @Value("${server.port}")
    private String appPort;

    @Resource
    WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @Resource
    Adminfenmemediafeign adminfenmemedia;

    @XxlJob("zidongshenhe")
    public ReturnT<String> hello(String param) throws Exception {
       List<Integer> wmNews= adminfenmemedia.zidongshenhe();
        if (!wmNews.isEmpty()){
            for (Integer id : wmNews) {

                wemediaNewsAutoScanService.autoScanBymedianewsid(id);

            }
        }


        System.out.println("自动审核："+ LocalDateTime.now()+",端口号"+appPort);

        return ReturnT.SUCCESS;
    }
}

